package com.cainiao.stock.controller.v1;

import com.cainiao.stock.annotation.Limiter;
import com.cainiao.stock.api.UserControllerAPI;
import com.cainiao.stock.dto.LoginDTO;
import com.cainiao.stock.enums.CodeEnum;
import com.cainiao.stock.exception.StockException;
import com.cainiao.stock.response.ResponseResult;
import com.cainiao.stock.service.UserService;
import com.cainiao.stock.vo.CaptchaVO;
import com.cainiao.stock.vo.LoginVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController implements UserControllerAPI {

    final UserService userService;

    public UserController(UserService userService) {
        this.userService = userService;
    }

    @Override
    public String getName() {
        //int i=1/0;
        return "欢迎来到今日指数项目";
    }

    @Override
    public ResponseResult<LoginVO> login(@RequestBody LoginDTO loginDTO) {
        return ResponseResult.ok(userService.selectByName(loginDTO));
    }

    @Limiter
    @Override
    public ResponseResult<CaptchaVO> captcha() {
        return ResponseResult.ok(userService.captcha());
    }


}
